import type { Extension } from "../Extension.ts";
import type { Mark } from "../Mark.ts";
import type { Node } from "../Node.ts";
import type { Extensions } from "../types.ts";

//分割扩展
export function splitExtensions(
  extensions: Extensions,
): Record<string, Extensions> {
  const baseExtensions = extensions.filter((extension) =>
    extension.type === "extension"
  ) as Extension[];
  const nodeExtensions = extensions.filter((extension) =>
    extension.type === "node"
  ) as Node[];
  const markExtensions = extensions.filter((extension) =>
    extension.type === "mark"
  ) as Mark[];

  return {
    baseExtensions,
    nodeExtensions,
    markExtensions,
  };
}
